﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace DRSM
{
    public partial class SupportPersonnel : Form
    {
        bool nameOfPersonnel = false;
        bool personnelID = false;
        bool empty = false;
        //bool notSimilarName = false;
        bool yearsOfExperience = false;
        bool servicesProvided = false;
        bool personnel = false;
        bool nonNumberEntered = false;


        public SupportPersonnel()
        {
            InitializeComponent();

            this.lblTime.Text = DateTime.Now.ToString();
            this.timer1.Start();
            this.timer2.Start();

            DataGridView[] dgvArray = new DataGridView[] { DGVDelPersonnel, dataGridViewAllSupportPersonnel };

            foreach (DataGridView _dgv in dgvArray)
            {

                _dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;    //
                _dgv.MultiSelect = true;   //
                _dgv.RowPrePaint += new DataGridViewRowPrePaintEventHandler(dgv_RowPrePaint);  //
            }
        }
        private void dgv_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
        {  //


            e.PaintParts &= ~DataGridViewPaintParts.Focus;


        }    // Select whole rows..

        private void SupportPersonnel_Load(object sender, EventArgs e)
        {
            pnlUpdateSearchPersonnel.Hide();
            pnlAssignDelete.Hide();
            pnlAssignPhysicalAid.Hide();
            pnlAssignUpdate.Hide();
            pnlDeletePersonnel.Hide();
            //pnlViewAllSupportPersonnel.Hide();
            pnlAddPersonnel.Show();
            pnlUpdateSearchPersonnel.Hide();
            pnlUpdatePersonnelDetails.Hide();
        }

        private void lblAddPersonel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            pnlAssignDelete.Hide();
            pnlAssignPhysicalAid.Hide();
            pnlAssignUpdate.Hide();
            pnlDeletePersonnel.Hide();
            //pnlDeleteSupportPersonnel.Hide();
            pnlUpdateSearchPersonnel.Hide();
            pnlViewAllSupportPersonnel.Hide();
            pnlAddPersonnel.Show();
            pnlUpdateSearchPersonnel.Hide();
            pnlUpdatePersonnelDetails.Hide();

        }

        private void lblUpdatePesonnel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            pnlUpdateSearchPersonnel.Show();
            pnlAddPersonnel.Hide();
            pnlAssignPhysicalAid.Hide();
            pnlAssignDelete.Hide();
            pnlAssignUpdate.Hide();
            pnlDeletePersonnel.Hide();
            //pnlDeleteSupportPersonnel.Hide();
            pnlUpdateAssign.Hide();
            pnlViewAllSupportPersonnel.Hide();
            pnlViewAssign.Hide();
            pnlUpdatePersonnelDetails.Hide();
            dbmanager.GetAllPersonnel();

        }

        private void lblDeletePersonnel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            pnlDeletePersonnel.Show();
            pnlUpdateSearchPersonnel.Hide();
            pnlAssignDelete.Hide();
            pnlAssignPhysicalAid.Hide();
            pnlAssignUpdate.Hide();
            pnlViewAllSupportPersonnel.Hide();
            pnlAddPersonnel.Hide();
            pnlUpdatePersonnelDetails.Hide();
            pnlUpdateSearchPersonnel.Hide();
            pnlDeleteSinglePersonnel.Hide();
            pnlDeleteMultiPersonnel.Show();
            //pnlDeleteSupportPersonnel.Hide();
            pnlDeleteSinglePersonnel.Hide();
            dbmanager.GetAllPersonnel();
            DGVDelPersonnel.DataSource = null;
            DGVDelPersonnel.Refresh();
            if (AllFormClass.SupportPersonnels.Count > 0)
            {
                DGVDelPersonnel.DataSource = AllFormClass.SupportPersonnels;
                DGVDelPersonnel.Refresh();
            }


        }


        private void pnlViewAllSupportPersonnel_Paint(object sender, PaintEventArgs e)
        {
            pnlUpdateSearchPersonnel.Hide();
            pnlAddPersonnel.Hide();
            pnlAssignPhysicalAid.Hide();
            pnlAssignDelete.Hide();
            pnlAssignUpdate.Hide();
            pnlDeletePersonnel.Hide();
            //pnlDeleteSupportPersonnel.Hide();
            pnlUpdateAssign.Hide();
            pnlUpdateSearchPersonnel.Hide();
            pnlViewAllSupportPersonnel.Show();
            pnlViewAssign.Hide();
            pnlUpdatePersonnelDetails.Hide();

        }

        private void ViewAllSupportPersonnelSub_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            pnlAddPersonnel.Hide();
            pnlAssignPhysicalAid.Hide();
            pnlAssignDelete.Hide();
            pnlAssignUpdate.Hide();
            pnlDeletePersonnel.Hide();
            //pnlDeleteSupportPersonnel.Hide();
            pnlUpdateAssign.Hide();
            pnlUpdateSearchPersonnel.Hide();
            pnlViewAllSupportPersonnel.Show();
            pnlViewAssign.Hide();
            pnlUpdatePersonnelDetails.Hide();
            pnlUpdateSearchPersonnel.Hide();

            SupportPersonnelControl.ViewPersonnel(dataGridViewAllSupportPersonnel);
            /* int rowCount = dataGridViewAllSupportPersonnel.RowCount;
             for (int x = 0; x < rowCount; x++)
             {
                 dataGridViewAllSupportPersonnel.Rows.Clear();
             }
             for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
             {
                 SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
                 dataGridViewAllSupportPersonnel.Rows.Add();
                 dataGridViewAllSupportPersonnel.Rows[i].Cells[0].Value = s.PersonnelIC;
                 dataGridViewAllSupportPersonnel.Rows[i].Cells[1].Value = s.NameOfPersonnel;
                 dataGridViewAllSupportPersonnel.Rows[i].Cells[2].Value = s.YearsOfExperience;
                 dataGridViewAllSupportPersonnel.Rows[i].Cells[3].Value = s.TypeOfPersonnel;
                 dataGridViewAllSupportPersonnel.Rows[i].Cells[4].Value = s.ServiceProvided;
             }*/
        }

        private void lblAssignPhysicalAid_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            pnlAddPersonnel.Hide();
            pnlAssignPhysicalAid.Show();
            pnlAssignDelete.Hide();
            pnlAssignUpdate.Hide();
            pnlDeletePersonnel.Hide();
            //pnlDeleteSupportPersonnel.Hide();
            pnlUpdateAssign.Hide();
            pnlUpdateSearchPersonnel.Hide();
            pnlViewAllSupportPersonnel.Hide();
            pnlViewAssign.Hide();
            pnlUpdatePersonnelDetails.Hide();
            pnlUpdateSearchPersonnel.Hide();

            if (cbxAssignNameOfPersonnel.Items.Count > 0)
            {
                cbxAssignNameOfPersonnel.Items.Clear();
            }
            for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
            {
                SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
                cbxAssignNameOfPersonnel.Items.Add(s.NameOfPersonnel + s.CityAssigned1);
            }

            DGVassignedPhysicalAid.DataSource = null;
            DGVassignedPhysicalAid.Refresh();

            if (AllFormClass.PhysicalAids.Count > 0)
            {
                DGVassignedPhysicalAid.DataSource = AllFormClass.PhysicalAids;
                DGVassignedPhysicalAid.Refresh();
            }


            //int rowCount = DGVassignedPhysicalAid.RowCount;
            //for (int x = 0; x < rowCount; x++)
            //{
            //    DGVassignedPhysicalAid.Rows.Clear();
            //}
            //for (int i = 0; i < AllFormClass.PhysicalAids.Count; i++)
            //{

            //    PhysicalAids p = (PhysicalAids)AllFormClass.PhysicalAids[i];

            //    DGVassignedPhysicalAid.Rows.Add();
            //    DGVassignedPhysicalAid.Rows[i].Cells[0].Value = p.ItemID;
            //    DGVassignedPhysicalAid.Rows[i].Cells[1].Value = p.ItemName;
            //    DGVassignedPhysicalAid.Rows[i].Cells[2].Value = p.Quantity;
            //}

        }

        private void lblUpdateAssignPhysicalAid_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            pnlAddPersonnel.Hide();
            pnlAssignPhysicalAid.Hide();
            pnlAssignDelete.Hide();
            pnlAssignUpdate.Show();
            pnlDeletePersonnel.Hide();
            //pnlDeleteSupportPersonnel.Hide();
            pnlUpdateSearchPersonnel.Hide();
            pnlViewAllSupportPersonnel.Hide();
            pnlViewAssign.Hide();
            pnlUpdatePersonnelDetails.Hide();
            pnlUpdateSearchPersonnel.Hide();

        }

        private void lblDeleteAssignedPhysicalAid_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            pnlAddPersonnel.Hide();
            pnlAssignPhysicalAid.Hide();
            pnlAssignDelete.Show();
            pnlAssignUpdate.Hide();
            pnlDeletePersonnel.Hide();
            //pnlDeleteSupportPersonnel.Hide();
            pnlUpdateSearchPersonnel.Hide();
            pnlViewAllSupportPersonnel.Hide();
            pnlViewAssign.Hide();
            pnlUpdatePersonnelDetails.Hide();
            pnlUpdateSearchPersonnel.Hide();


        }

        private void lblViewAllSupportPersonnel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            pnlAddPersonnel.Hide();
            pnlAssignPhysicalAid.Hide();
            pnlAssignDelete.Hide();
            pnlAssignUpdate.Hide();
            pnlDeletePersonnel.Hide();
            //pnlDeleteSupportPersonnel.Hide();
            pnlUpdateSearchPersonnel.Hide();
            pnlViewAllSupportPersonnel.Show();
            pnlViewAssign.Hide();
            pnlUpdatePersonnelDetails.Hide();
            pnlUpdateSearchPersonnel.Hide();

            int rowCount = dataGridView1.RowCount;
            for (int x = 0; x < rowCount; x++)
            {
                dataGridView1.Rows.Clear();

            }
            for (int i = 0; i < AllFormClass.PhysicalAids.Count; i++)
            {
                SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
                PhysicalAids p = (PhysicalAids)AllFormClass.PhysicalAids[i];

                dataGridView1.Rows[i].Cells[1].Value = p.ItemName; dataGridView1.Rows.Add();
                dataGridView1.Rows[i].Cells[0].Value = s.NameOfPersonnel;

            }



        }

        private void dataGridViewDiagnosis_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void tbxUpdateAssignPatient_TextChanged(object sender, EventArgs e)
        {

        }

        private void btnAffectedCities_Click(object sender, EventArgs e)
        {

            AllFormClass.ac.Show();
            this.Hide();
        }

        private void btnPhysicalAid_Click(object sender, EventArgs e)
        {
            AllFormClass.pa.Show();
            this.Hide();
        }

        private void btnSupportedPersonnel_Click(object sender, EventArgs e)
        {

        }
        int count = 0;
        private void btnAddSupportPersonnel_Click(object sender, EventArgs e)
        {
            SupportPersonnelControl.AddPersonnel(count, tbxNameVerify, tbxPersonnelIDVerify, tbxYearsOfExperience,
             tbxServicesProvide, cbxTypeOfPersonnel, cbxID);

            /*count++;
            string nameOfPersonnel = tbxNameVerify.Text.Trim();
            string personnelID = tbxPersonnelIDVerify.Text.Trim();
            string yearsOfExperience = tbxYearsOfExperience.Text.Trim();
            string serviceProvide = tbxServicesProvide.Text.Trim();
            string typeOfPersonnel = cbxTypeOfPersonnel.Text;
            string cityAssigned = "NILL";
           

            //generate a random personnelID
            //
             * 
             * 
             * 
             *r = new Random();
            //int randomID = r.Next(1000000, 9999999);

            //foreach (SupportPersonnels sp in AllFormClass.SupportPersonnels)
            //{
            //    while (sp.randomidNo == randomID)
            //    {
            //        randomID = r.Next(1000000, 9999999);
            //        if (sp.randomidNo != randomID)
            //        {
            //            break;
            //        }
            //    }
                  
            //}
            int num = 1000000;
            num = num + count;
               

            bool empty = false;
            bool icInvalid = false;

            if (empty == false && icInvalid == false)
            {
                string icNum = (cbxID.Text + tbxPersonnelIDVerify.Text);
                SupportPersonnels s = new SupportPersonnels (num, tbxNameVerify.Text, icNum, tbxYearsOfExperience.Text, tbxServicesProvide.Text, typeOfPersonnel, cityAssigned);
                AllFormClass.SupportPersonnels.Add(s);

                MessageBox.Show("Personnel Added Successfully!! ");
            }
            tbxNameVerify.Clear();
            tbxPersonnelIDVerify.Clear();
            tbxYearsOfExperience.Clear();
            tbxServicesProvide.Clear();
            cbxID.SelectedIndex = 0;
            cbxTypeOfPersonnel.SelectedIndex = 0;*/

        }

        ////private void btnUpdateSearch_Click(object sender, EventArgs e)
        ////{
        ////    int count = 0;
        ////    string input = tbxUpdateSearch.Text.Trim();
        ////    if (input.Length == 0)
        ////    {
        ////        if (cbxUpdateDatabaseSearch.Visible == true)
        ////        {
        ////            cbxUpdateDatabaseSearch.ForeColor = Color.Red;
        ////        }
        ////        tbxUpdateSearch.Focus();
        ////    }
        ////    else
        ////    {
        ////        cbxUpdateDatabaseSearch.ForeColor = Color.DimGray;
        ////        lbxSearchResult.Items.Clear();
        ////        if (cbxUpdateDatabaseSearch.SelectedIndex == 0)
        ////        {
        ////            for (int x = 0; x < AllFormClass.SupportPersonnels.Count; x++)
        ////            {
        ////                SupportPersonnels sp = (SupportPersonnels)AllFormClass.SupportPersonnels[x];
        ////                Boolean result = sp.NameOfPersonnel.Contains(tbxUpdateSearch.Text.ToUpper());

        ////                if (result == true)
        ////                {
        ////                    lbxSearchResult.Items.AddRange(new object[] { sp.PersonnelID });
        ////                    count++;
        ////                }

        ////            }
        ////        }
        ////        if (count != 0)
        ////        {
        ////            pnlUpdateSearchResult.Show();
        ////        }
        ////        else
        ////        {
        ////            MessageBox.Show("No result found. Please add new personnel instead");
        ////        }
        ////    }

        ////}

        ////private void btnSearchSelect_Click(object sender, EventArgs e)
        //{
        //    for(int i = 0; i< AllFormClass.SupportPersonnels.Count; i++)
        //    {
        //        // get the result from the list box
        //        SupportPersonnels s = (SupportPersonnels)lbxSearchResult.SelectedItem;

        //        tbxUpdateName.Text = s.NameOfPersonnel;
        //        char typeOfPersonnel = s.TypeOfPersonnel[0];
        //        if (typeOfPersonnel.Equals("Medical"))
        //        {
        //            comboBoxtypeOfPersonnel.SelectedIndex = 0;
        //        }
        //        else if (typeOfPersonnel.Equals("Millitary"))
        //        {
        //            comboBoxtypeOfPersonnel.SelectedIndex = 1;
        //        }
        //        else if(typeOfPersonnel.Equals("Volunteer"))
        //        {
        //            comboBoxtypeOfPersonnel.SelectedIndex = 2;
        //        }
        //        tbxUpdateServicesProvide.Text = s.ServiceProvided;
        //        tbxYearsOfExperience.Text = s.YearsOfExperience;
        //        tbxPersonnelIDVerify.Text = s.PersonnelID;

        //        pnlUpdatePersonnel.Show();
        //        pnlUpdateSearchResult.Hide();
        //    }
        //}

        //private void listBoxDeleteResultPersonnel_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    pnlDeleteSupportPersonnel.Show();
        //    string selectedPersonnel = listBoxDeleteResultPersonnel.SelectedItem.ToString();
        //    foreach (SupportPersonnels SupportPersonnels in AllFormClass.SupportPersonnels)
        //    {
        //        if (SupportPersonnels.NameOfPersonnel == selectedPersonnel)
        //        {
        //            lblDeletePersonnelName.Text = SupportPersonnels.NameOfPersonnel;
        //            lblDeletePersonnelID.Text = SupportPersonnels.PersonnelID;
        //            lblDeleteYearsOfExperience.Text = SupportPersonnels.YearsOfExperience;
        //            lblDeleteServicesProvided.Text = SupportPersonnels.ServiceProvided;
        //            lblDeleteTypeOfPersonnel.Text = Convert.ToString(SupportPersonnels.TypeOfPersonnel);
        //        }
        //    }
        //}

        //private void btnDelete_Click(object sender, EventArgs e)
        //{
        //    string selectedPersonnel = listBoxDeleteResultPersonnel.SelectedItem.ToString();
        //    for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
        //    {
        //        SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
        //        if (s.NameOfPersonnel == selectedPersonnel)
        //        {
        //            AllFormClass.AffectedCity.RemoveAt(i);
        //            MessageBox.Show("Personnel is removed successfully!!");
        //        }
        //    }
        //}





        //private void tbxDeleteSearch_TextChanged(object sender, EventArgs e)
        //{
        //    char firstChar = '0';
        //    this.listBoxDeleteResultPersonnel.Items.Clear();

        //    if (listBoxDeleteResultPersonnel.Text != String.Empty)
        //    {
        //        if (firstChar != listBoxDeleteResultPersonnel.Text[0])
        //        {
        //            firstChar = listBoxDeleteResultPersonnel.Text[0];

        //            for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
        //            {
        //                SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
        //                String searchPersonnel = s.NameOfPersonnel.ToString();
        //                if (searchPersonnel[0] == firstChar)
        //                {
        //                    listBoxDeleteResultPersonnel.DisplayMember = "FirstName";
        //                    listBoxDeleteResultPersonnel.Items.Add(s.NameOfPersonnel);

        //                }
        //            }
        //        }
        //    }
        //}




        //private void cbxDeleteSearch_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    tbxDeleteSearch.AutoCompleteCustomSource.Clear();
        //    for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
        //    {
        //        if (cbxDeleteSearch.SelectedIndex == 0)
        //        {
        //            SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
        //            tbxDeleteSearch.AutoCompleteCustomSource.Add(s.PersonnelIC);
        //        }
        //        if (cbxDeleteSearch.SelectedIndex == 1)
        //        {
        //            SupportPersonnels s1 = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
        //            tbxDeleteSearch.AutoCompleteCustomSource.Add(s1.NameOfPersonnel);
        //        }
        //    }
        //    tbxDeleteSearch.Focus();
        //}

        //private void btnDeleteSearch_Click(object sender, EventArgs e)
        //{
        //    string input = tbxDeleteSearch.Text.Trim();
        //    if (input.Length == 0)
        //    {
        //        cbxDeleteSearch.ForeColor = Color.Red;
        //        tbxDeleteSearch.Focus();
        //    }
        //    else
        //    {
        //        cbxDeleteSearch.ForeColor = Color.Black;
        //        pnlDeleteSupportPersonnel.Show();
        //        listBoxDeleteResultPersonnel.Items.Clear();
        //        if (cbxDeleteSearch.SelectedItem.Equals("Personnel ID "))
        //        {
        //            for(int x = 0; x< AllFormClass.SupportPersonnels.Count; x++)
        //            {
        //                SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[x];
        //                string searchPersonnel = s.PersonnelIC.ToString();
        //                if (searchPersonnel.Contains(tbxDeleteSearch.Text))
        //                {
        //                    listBoxDeleteResultPersonnel.DisplayMember = "Personnel ID";
        //                    listBoxDeleteResultPersonnel.Items.Add(AllFormClass.SupportPersonnels[x]);
        //                }
        //            }
        //        }
        //            else if(cbxDeleteSearch.SelectedItem.Equals("Name"))
        //            {
        //                for( int x=0; x<AllFormClass.SupportPersonnels.Count; x++)
        //                {
        //                    SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[x];
        //                    string searchPersonnel = s.NameOfPersonnel;
        //                    if (searchPersonnel.Contains(tbxDeleteSearch.Text))
        //                    {
        //                        listBoxDeleteResultPersonnel.DisplayMember = "Name";
        //                        listBoxDeleteResultPersonnel.Items.Add(AllFormClass.SupportPersonnels[x]);
        //                    }
        //                }
        //            }
        //        }
        //    }

        private void listBoxDeleteResultPersonnel_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void tbxNameVerify_TextChanged(object sender, EventArgs e)
        {
            nameOfPersonnel = tbxNameVerify.Text != "";
            if (nameOfPersonnel && personnelID && yearsOfExperience && empty && personnel
                && servicesProvided)
            {
                this.btnAddSupportPersonnel.Enabled = true;
            }
            else
            {
                this.btnAddSupportPersonnel.Enabled = false;
            }
        }

        private void tbxPersonnelIDVerify_TextChanged(object sender, EventArgs e)
        {
            personnelID = tbxPersonnelIDVerify.Text != "";
            if (nameOfPersonnel && personnelID && yearsOfExperience && empty && personnel
                && servicesProvided)
            {
                this.btnAddSupportPersonnel.Enabled = true;
            }
            else
            {
                this.btnAddSupportPersonnel.Enabled = false;
            }
        }

        private void cbxID_SelectedIndexChanged(object sender, EventArgs e)
        {
            //if (cbxID.SelectedIndex > -1)
            //{
            //    empty = true;
            //}
            //if (notSimilarName && nameOfPersonnel && personnelID && empty && yearsOfExperience
            //      && servicesProvided && personnel)
            //{
            //    this.btnAddSupportPersonnel.Enabled = true;
            //}
            //else
            //{
            //    this.btnAddSupportPersonnel.Enabled = false;
            //}
        }

        private void tbxYearsOfExperience_TextChanged(object sender, EventArgs e)
        {
            yearsOfExperience = tbxYearsOfExperience.Text != "";
            if (nameOfPersonnel && personnelID && yearsOfExperience && empty && personnel
               && servicesProvided)
            {
                this.btnAddSupportPersonnel.Enabled = true;
            }
            else
            {
                this.btnAddSupportPersonnel.Enabled = false;
            }
        }

        private void tbxServicesProvide_TextChanged(object sender, EventArgs e)
        {
            servicesProvided = tbxServicesProvide.Text != "";
            if (nameOfPersonnel && personnelID && yearsOfExperience && empty && personnel
               && servicesProvided)
            {
                this.btnAddSupportPersonnel.Enabled = true;
            }
            else
            {
                this.btnAddSupportPersonnel.Enabled = false;
            }
        }

        private void cbxID_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            if (cbxID.SelectedIndex > -1)
            {
                empty = true;

                if (nameOfPersonnel && personnelID && yearsOfExperience && empty && personnel
                    && servicesProvided)
                {
                    this.btnAddSupportPersonnel.Enabled = true;
                }
                else
                {
                    this.btnAddSupportPersonnel.Enabled = false;
                }
            }
        }

        private void cbxTypeOfPersonnel_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbxTypeOfPersonnel.SelectedIndex > -1)
            {
                personnel = true;
                if (nameOfPersonnel && personnelID && yearsOfExperience && empty && personnel
                    && servicesProvided)
                {
                    this.btnAddSupportPersonnel.Enabled = true;
                }
                else
                {
                    this.btnAddSupportPersonnel.Enabled = false;
                }
            }
        }

        private void tbxYearsOfExperience_KeyDown(object sender, KeyEventArgs e)
        {
            // Initialize the flag to false.
            nonNumberEntered = false;

            // Determine whether the keystroke is a number from the top of the keyboard.
            if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9)
            {
                // Determine whether the keystroke is a number from the keypad.
                if (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9)
                {
                    // Determine whether the keystroke is a backspace.
                    if (e.KeyCode != Keys.Back)
                    {
                        // A non-numerical keystroke was pressed.
                        // Set the flag to true and evaluate in KeyPress event.
                        nonNumberEntered = true;
                    }
                }
            }
            //If shift key was pressed, it's not a number.
            if (Control.ModifierKeys == Keys.Shift)
            {
                nonNumberEntered = true;
            }
        }

        private void tbxYearsOfExperience_KeyPress(object sender, KeyPressEventArgs e)
        {
            // Check for the flag being set in the KeyDown event.
            if (nonNumberEntered == true)
            {
                // Stop the character from being entered into the control since it is non-numerical.
                e.Handled = true;
            }
        }

        private void cbxUpdateSearch_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            tbxUpdateSearch.Enabled = true;
            for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
            {
                if (cbxUpdateSearch.SelectedIndex == 0)
                {
                    SupportPersonnels s1 = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
                    tbxUpdateSearch.AutoCompleteCustomSource.Add(s1.NameOfPersonnel);
                }
                if (cbxUpdateSearch.SelectedIndex == 1)
                {
                    SupportPersonnels s2 = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
                    tbxUpdateSearch.AutoCompleteCustomSource.Add(s2.PersonnelIC);
                }
            }
        }

        private void tbxUpdateSearch_TextChanged(object sender, EventArgs e)
        {
            //SupportPersonnelControl.UpdateSearch(lbxSearchResult, cbxUpdateSearch, tbxUpdateSearch);
            this.lbxSearchResult.Items.Clear();
            if (cbxUpdateSearch.SelectedItem == null) { }

            else if (cbxUpdateSearch.SelectedItem.Equals("Support Personnel Name"))
            {

                for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
                {
                    SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
                    string searchPersonnel = s.NameOfPersonnel;
                    if (searchPersonnel.Contains(tbxUpdateSearch.Text))
                    {
                        lbxSearchResult.DisplayMember = "NameOfPersonnel";
                        lbxSearchResult.Items.Add(AllFormClass.SupportPersonnels[i]);
                    }

                }
            }
            else if (cbxUpdateSearch.SelectedItem.Equals("Personnel ID"))
            {

                for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
                {
                    SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
                    string searchPersonnel = s.PersonnelIC.ToString();
                    if (searchPersonnel.Contains(tbxUpdateSearch.Text))
                    {
                        lbxSearchResult.DisplayMember = "personnelIC";
                        lbxSearchResult.Items.Add(AllFormClass.SupportPersonnels[i]);
                    }
                }
            }
        }

        private void btnSearchUpdatePersonnel_Click(object sender, EventArgs e)
        {
            //SupportPersonnelControl.SearchUpdatePersonnel(lbxSearchResult, tbxUpdateNameOfPersonnel, cbxUpdateID,
            // tbxUpdatePersonnelNo, tbxUpdateID, tbxUpdateYearsOfExperience, tbxUpdateServicesProvided,
            //  cbxUpdateTypeOfPersonnel, pnlUpdatePersonnelDetails);
            try
            {
                foreach (SupportPersonnels SupportPersonnels in AllFormClass.SupportPersonnels)
                {
                    SupportPersonnels s1 = (SupportPersonnels)lbxSearchResult.SelectedItem;

                    tbxUpdateNameOfPersonnel.Text = s1.NameOfPersonnel;
                    char idType = s1.PersonnelIC[0];
                    if (idType.Equals('S'))
                    {
                        cbxUpdateID.SelectedIndex = 0;
                    }
                    else if (idType.Equals('F'))
                    {
                        cbxUpdateID.SelectedIndex = 1;
                    }
                    else if (idType.Equals('T'))
                    {
                        cbxUpdateID.SelectedIndex = 2;
                    }
                    else if (idType.Equals('G'))
                    {
                        cbxUpdateID.SelectedIndex = 3;
                    }
                    tbxUpdatePersonnelNo.Text = Convert.ToString(SupportPersonnels.personnelID);
                    tbxUpdateID.Text = s1.PersonnelIC.Remove(0, 1);
                    tbxUpdateYearsOfExperience.Text = s1.YearsOfExperience;
                    tbxUpdateServicesProvided.Text = s1.ServiceProvided;

                    char typeofPersonnel = s1.TypeOfPersonnel[0];
                    if (s1.TypeOfPersonnel == ("Medical"))
                    {
                        cbxUpdateTypeOfPersonnel.SelectedIndex = 0;
                    }
                    else if (typeofPersonnel.Equals("Military"))
                    {
                        cbxUpdateTypeOfPersonnel.SelectedIndex = 1;
                    }
                    else if (typeofPersonnel.Equals("Volunteer"))
                    {
                        cbxUpdateTypeOfPersonnel.SelectedIndex = 2;
                    }
                    tbxUpdatePersonnelNo.Text = s1.personnelID.ToString();

                    pnlUpdatePersonnelDetails.Show();
                }
            }

            catch (NullReferenceException)
            {
                MessageBox.Show("Error: No personnel is selected!");
            }
        }


        private void btnUpdatePersonnel_Click(object sender, EventArgs e)
        {
            SupportPersonnelControl.UpdatePersonnel(tbxUpdatePersonnelNo, cbxUpdateID, tbxUpdateID,
            tbxUpdateNameOfPersonnel, tbxUpdateServicesProvided, tbxUpdateYearsOfExperience,
            cbxUpdateTypeOfPersonnel);
            MessageBox.Show("Personnel Updated Successfully!! ");
            //try
            //{
            //    foreach (SupportPersonnels SupportPersonnels in AllFormClass.SupportPersonnels)
            //    {
            //        if (Convert.ToString(SupportPersonnels.personnelID) == tbxUpdatePersonnelNo.Text)
            //        {
            //            string icNum = (cbxUpdateID.Text + tbxUpdateID.Text);
            //            SupportPersonnels.personnelID = Convert.ToInt32(tbxUpdatePersonnelNo.Text);
            //            SupportPersonnels.NameOfPersonnel = tbxUpdateNameOfPersonnel.Text;
            //            SupportPersonnels.PersonnelIC = icNum;
            //            SupportPersonnels.ServiceProvided = tbxUpdateServicesProvided.Text;
            //            SupportPersonnels.YearsOfExperience = tbxUpdateYearsOfExperience.Text;
            //            SupportPersonnels.TypeOfPersonnel = cbxUpdateTypeOfPersonnel.Text;



            //            //string nameOfPersonnel = tbxUpdateNameOfPersonnel.Text.Trim();
            //            //string id = tbxUpdateID.Text.Trim();
            //            //string yearsOfExperience = tbxUpdateYearsOfExperience.Text.Trim();
            //            //string serviceProvided = tbxServicesProvide.Text.Trim();
            //            //string typeOfPersonnel = cbxUpdateTypeOfPersonnel.Text;



            //             MessageBox.Show("Personnel Updated Successfully!! ");

            //            }
            //        }
            //    }

            //           catch(InvalidOperationException){
            //               MessageBox.Show("Error!");
            //           }

        }

        //private void tbxDeleteSearch_TextChanged(object sender, EventArgs e)
        //{
        //     string input = tbxDeleteSearch.Text.Trim();
        //    if (input.Length == 0)
        //    {
        //        cbxDeleteSearch.ForeColor = Color.Red;
        //        tbxDeleteSearch.Focus();
        //    }
        //    else
        //    {
        //        cbxDeleteSearch.ForeColor = Color.Black;
        //        pnlDeleteSupportPersonnel.Show();
        //        listBoxDeleteResultPersonnel.Items.Clear();
        //        if (cbxDeleteSearch.SelectedItem.Equals("Personnel ID "))
        //        {
        //            for(int x = 0; x< AllFormClass.SupportPersonnels.Count; x++)
        //            {
        //                SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[x];
        //                string searchPersonnel = s.PersonnelIC.ToString();
        //                if (searchPersonnel.Contains(tbxDeleteSearch.Text))
        //                {
        //                    listBoxDeleteResultPersonnel.DisplayMember = "Personnel ID";
        //                    listBoxDeleteResultPersonnel.Items.Add(AllFormClass.SupportPersonnels[x]);
        //                }
        //            }
        //        }
        //            else if(cbxDeleteSearch.SelectedItem.Equals("Name"))
        //            {
        //                for( int x=0; x<AllFormClass.SupportPersonnels.Count; x++)
        //                {
        //                    SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[x];
        //                    string searchPersonnel = s.NameOfPersonnel;
        //                    if (searchPersonnel.Contains(tbxDeleteSearch.Text))
        //                    {
        //                        listBoxDeleteResultPersonnel.DisplayMember = "Name";
        //                        listBoxDeleteResultPersonnel.Items.Add(AllFormClass.SupportPersonnels[x]);
        //                    }
        //                }
        //            }
        //        }
        //    }

        //private void radioBtnDelSinglePersonnel_CheckedChanged(object sender, EventArgs e)
        //{
        //    if (radioBtnDelSinglePersonnel.Checked.Equals(true))
        //    {
        //        pnlDeleteSinglePersonnel.Show();
        //        pnlDeleteMultiPersonnel.Hide();
        //    }
        //}

        private void cbxDeleteSearch_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
            {
                if (cbxDeleteSearch.SelectedIndex == 0)
                {
                    SupportPersonnels s1 = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
                    tbxDeleteSearch.AutoCompleteCustomSource.Add(s1.NameOfPersonnel);
                }
                if (cbxDeleteSearch.SelectedIndex == 1)
                {
                    SupportPersonnels s2 = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
                    tbxDeleteSearch.AutoCompleteCustomSource.Add(s2.PersonnelIC);
                }
            }
        }

        private void tbxDeleteSearch_TextChanged_1(object sender, EventArgs e)
        {
            this.searchDeletePersonnelResult.Items.Clear();

            if (cbxDeleteSearch.SelectedItem.Equals("Support Personnel Name"))
            {
                for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
                {
                    SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
                    string searchPersonnel = s.NameOfPersonnel;
                    if (searchPersonnel.Contains(tbxDeleteSearch.Text))
                    {
                        searchDeletePersonnelResult.DisplayMember = "NameOfPersonnel";
                        searchDeletePersonnelResult.Items.Add(s.NameOfPersonnel);
                    }

                }
            }
            else if (cbxDeleteSearch.SelectedItem.Equals("Personnel ID"))
            {
                for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
                {
                    SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
                    string searchPersonnel = s.PersonnelIC.ToString();
                    if (searchPersonnel.Contains(tbxDeleteSearch.Text))
                    {
                        searchDeletePersonnelResult.DisplayMember = "personnelIC;";
                        searchDeletePersonnelResult.Items.Add(s.PersonnelIC);
                    }
                }
            }
        }

        private void searchDeletePersonnelResult_SelectedIndexChanged(object sender, EventArgs e)
        {
            //SupportPersonnelControl.SearchDelete(pnlDeletePersonnelDetails, searchDeletePersonnelResult,
            //lblDeleteNameOfPersonnel, lblDeletePersonnelIC, lblDeleteYearsOfExperience, lblDeleteServicesProvided,
            // lblDeleteTypeOfPersonnel);

            pnlDeletePersonnelDetails.Show();
            string selectedPersonnel = searchDeletePersonnelResult.SelectedItem.ToString();
            string selectedIc = searchDeletePersonnelResult.SelectedItem.ToString();
            foreach (SupportPersonnels SupportPersonnels in AllFormClass.SupportPersonnels)
            {
                if (SupportPersonnels.NameOfPersonnel == selectedPersonnel)
                {
                    lblDeleteNameOfPersonnel.Text = SupportPersonnels.NameOfPersonnel;
                    lblDeletePersonnelIC.Text = SupportPersonnels.PersonnelIC;
                    lblDeleteYearsOfExperience.Text = SupportPersonnels.YearsOfExperience;
                    lblDeleteServicesProvided.Text = SupportPersonnels.ServiceProvided;
                    lblDeleteTypeOfPersonnel.Text = SupportPersonnels.TypeOfPersonnel;
                }

                else if (SupportPersonnels.PersonnelIC == selectedIc)
                {
                    lblDeleteNameOfPersonnel.Text = SupportPersonnels.NameOfPersonnel;
                    lblDeletePersonnelIC.Text = SupportPersonnels.PersonnelIC;
                    lblDeleteYearsOfExperience.Text = SupportPersonnels.YearsOfExperience;
                    lblDeleteServicesProvided.Text = SupportPersonnels.ServiceProvided;
                    lblDeleteTypeOfPersonnel.Text = SupportPersonnels.TypeOfPersonnel;
                }
            }
        }

        //private void btnDelete_Click(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        foreach (SupportPersonnels SupportPersonnels in AllFormClass.SupportPersonnels)
        //        {
        //            if (Convert.ToString(SupportPersonnels.randomidNo) == tbxUpdatePersonnelNo.Text)
        //            {
        //                string icNum = (cbxUpdateID.Text + tbxUpdateID.Text);
        //                SupportPersonnels.randomidNo = Convert.ToInt32(tbxUpdatePersonnelNo.Text);
        //                SupportPersonnels.NameOfPersonnel = lblDeleteNameOfPersonnel.Text;
        //                SupportPersonnels.PersonnelIC = icNum;
        //                SupportPersonnels.ServiceProvided = tbxUpdateServicesProvided.Text;
        //                SupportPersonnels.YearsOfExperience = tbxUpdateYearsOfExperience.Text;
        //                SupportPersonnels.TypeOfPersonnel = cbxUpdateTypeOfPersonnel.Text;
        //    string selectedpersonnel = searchDeletePersonnelResult.SelectedItem.ToString();
        //    for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
        //    {
        //        SupportPersonnels sp = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
        //        if (sp.NameOfPersonnel == selectedpersonnel)
        //        {
        //            AllFormClass.SupportPersonnels.RemoveAt(i);
        //            MessageBox.Show("Personnel removed successfully!");
        //            tbxDeleteSearch.Clear();

        //        }
        //    }
        //}

        //private void radioBtnDelMultiPersonnel_CheckedChanged(object sender, EventArgs e)
        //{

        //    {
        //        pnlDeleteMultiPersonnel.Show();
        //        pnlDeleteSinglePersonnel.Hide();

        //        DGVDelPersonnel.DataSource = null;
        //        DGVDelPersonnel.Refresh();
        //        if (AllFormClass.SupportPersonnels.Count > 0)
        //        {
        //            DGVDelPersonnel.DataSource = AllFormClass.SupportPersonnels;
        //            DGVDelPersonnel.Refresh();
        //        }
        //    }
        //}


        private void btnDelMultiPersonnel_Click(object sender, EventArgs e)
        {
            ArrayList integer = new ArrayList();
            foreach (DataGridViewRow row in DGVDelPersonnel.SelectedRows)
            {
                integer.Add(row.Cells[0].Value);
            }
            SupportPersonnelControl.DeletePersonnel(integer, DGVDelPersonnel);

            //SupportPersonnelControl.DeletePersonnel(DGVDelPersonnel);

            /* foreach (DataGridViewRow row in DGVDelPersonnel.SelectedRows)
             {
                 int index = DGVDelPersonnel.CurrentCell.RowIndex;

                 sp = (SupportPersonnels)AllFormClass.SupportPersonnels[index];
                 AllFormClass.SupportPersonnels.Remove(sp);

                 DGVDelPersonnel.DataSource = null;
                 DGVDelPersonnel.Refresh();

                 DGVDelPersonnel.DataSource = AllFormClass.SupportPersonnels;
                 DGVDelPersonnel.Refresh();
            
             }*/
        }

        private void btnAssignSubmit_Click(object sender, EventArgs e)
        {

        }

        private void lbxAssignResultList_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void tbxAssignSearchInput_TextChanged(object sender, EventArgs e)
        {
            if (tbxAssignSearchInput.Text != String.Empty)
            {
                string search = tbxAssignSearchInput.Text;
                foreach (DataGridViewRow i in DGVassignedPhysicalAid.Rows)
                {
                    i.Selected = false;
                    try
                    {
                        string searchItem = i.Cells[1].Value.ToString();
                        if (searchItem.Contains(tbxAssignSearchInput.Text))
                        {
                            i.Selected = true;
                        }
                        else
                        {
                            i.Selected = false;
                        }
                    }
                    catch (NullReferenceException nre)
                    {
                        return;
                    }

                }
            }

        }

        private void pbxHeader_Click(object sender, EventArgs e)
        {

        }

        private void lbxSearchResult_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void pnlUpdatePersonnelDetails_Paint(object sender, PaintEventArgs e)
        {

        }


        private void btnAssignPersonnel_Click(object sender, EventArgs e)
        {
            ArrayList number = new ArrayList();
            foreach (DataGridViewRow row in DGVassignedPhysicalAid.SelectedRows)
            {
                number.Add(row.Cells[0].Value);
            }
            for (int i = AllFormClass.PhysicalAids.Count - 1; i >= 0; i--)
            {
                PhysicalAids p = (PhysicalAids)AllFormClass.PhysicalAids[i];
                for (int j = 0; j < number.Count; j++)
                {
                    if (p.ItemID == Convert.ToInt32(number[j]))
                    {
                        int initial = Convert.ToInt32(p.Quantity);
                        int now = Convert.ToInt32(tbxAssignQuantity.Text);
                        if (initial > now)
                        {
                            int remain = initial - now;
                            p.Quantity = remain.ToString();
                        }
                        DGVassignedPhysicalAid.DataSource = null;
                        DGVassignedPhysicalAid.Refresh();

                        if (AllFormClass.PhysicalAids.Count > 0)
                        {
                            DGVassignedPhysicalAid.DataSource = AllFormClass.PhysicalAids;
                            DGVassignedPhysicalAid.Refresh();
                        }
                    }
                }


            }
            //        int rowCount = DGVassignedPhysicalAid.RowCount;
            //        DGVassignedPhysicalAid.Refresh();
            //        for (int x = 0; x < rowCount; x++)
            //        {
            //            DGVassignedPhysicalAid.Rows.Clear();
            //        }
            //        for (int i = 0; i < AllFormClass.PhysicalAids.Count; i++)
            //        {

            //            PhysicalAids p = (PhysicalAids)AllFormClass.PhysicalAids[i];

            //            DGVassignedPhysicalAid.Rows.Add();
            //            DGVassignedPhysicalAid.Rows[i].Cells[0].Value = p.ItemID;
            //            DGVassignedPhysicalAid.Rows[i].Cells[1].Value = p.ItemName;
            //            DGVassignedPhysicalAid.Rows[i].Cells[2].Value = p.Quantity;


            //        }
        }

        //private void cbxAssignNameOfPersonnel_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    if (cbxAssignNameOfPersonnel.Items.Count > 0)
        //    {
        //        cbxAssignNameOfPersonnel.Items.Clear();
        //    }
        //    for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
        //    {
        //        SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
        //        cbxAssignNameOfPersonnel.Items.Add(s.CityAssigned1);
        //    }
        //}

        private void btnResetADD_Click(object sender, EventArgs e)
        {
            tbxNameVerify.Clear();
            tbxPersonnelIDVerify.Clear();
            tbxYearsOfExperience.Clear();
            tbxServicesProvide.Clear();
            cbxID.SelectedIndex = 0;
            cbxTypeOfPersonnel.SelectedIndex = 0;
        }

        private void btnResetPersonnel_Click(object sender, EventArgs e)
        {
            tbxUpdateNameOfPersonnel.Clear();
            tbxUpdatePersonnelNo.Clear();
            tbxUpdateServicesProvided.Clear();
            tbxUpdateYearsOfExperience.Clear();
            cbxUpdateID.SelectedIndex = 0;
            cbxUpdateTypeOfPersonnel.SelectedIndex = 0;
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void pnlAssignPhysicalAid_Paint(object sender, PaintEventArgs e)
        {

        }

        private void tbxSearchDGVDelAffectedCity_TextChanged(object sender, EventArgs e)
        {

            if (tbxSearchDGVDelPersonnel.Text != String.Empty)
            {
                String search = tbxSearchDGVDelPersonnel.Text;
                foreach (DataGridViewRow i in DGVDelPersonnel.Rows)
                {
                    i.Selected = false;
                    String searchItem = i.Cells[1].Value.ToString();
                    if (searchItem.Contains(tbxSearchDGVDelPersonnel.Text))
                    {
                        i.Selected = true;
                        //break;
                    }
                    else
                    {
                        i.Selected = false;
                        // break;
                    }
                }
            }
            else
            {
                foreach (DataGridViewRow i in DGVDelPersonnel.Rows)
                {
                    i.Selected = false;
                }

            }
        }

        private void btnDeleteAssign_Click(object sender, EventArgs e)
        {
            ArrayList number = new ArrayList();
            foreach (DataGridViewRow row in DGVassignedPhysicalAid.SelectedRows)
            {
                number.Add(row.Cells[0].Value);
            }
            for (int i = AllFormClass.PhysicalAids.Count - 1; i >= 0; i--)
            {
                PhysicalAids p = (PhysicalAids)AllFormClass.PhysicalAids[i];
                for (int j = 0; j < number.Count; j++)
                {
                    if (p.ItemID == Convert.ToInt32(number[j]))
                    {
                        int initial = Convert.ToInt32(p.Quantity);
                        int now = Convert.ToInt32(tbxAssignQuantity.Text);


                        int remain = initial + now;
                        p.Quantity = remain.ToString();

                        DGVassignedPhysicalAid.DataSource = null;
                        DGVassignedPhysicalAid.Refresh();

                        if (AllFormClass.PhysicalAids.Count > 0)
                        {
                            DGVassignedPhysicalAid.DataSource = AllFormClass.PhysicalAids;
                            DGVassignedPhysicalAid.Refresh();
                        }

                    }
                }


            }
        }

        private void lblLogout_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            DialogResult dr = MessageBox.Show("Are you sure you want to logout?",
                  "Warning",
                  MessageBoxButtons.YesNo,
                  MessageBoxIcon.Exclamation);

            if (dr == DialogResult.Yes)
            {
                AllFormClass.lp.Show();
                this.Hide();
            }
            else if (dr == DialogResult.No)
            {

            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.lblTime.Text = DateTime.Now.ToString();
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            foreach (user u in AllFormClass.User)
            {
                if (u.Name == u.Name)
                {
                    this.lblWelcome.Text = "Welcome, " + u.Name;
                }
            }
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {

        }



    }


}

//private void cbxTypeOfPersonnel_SelectedIndexChanged(object sender, EventArgs e)
//{
//    string typeOfPersonnel = cbxTypeOfPersonnel.Text;
//    if (cbxTypeOfPersonnel.SelectedIndex > -1)
//    {
//        personnel = true;
//        if (notSimilarName && nameOfPersonnel && personnelID && empty && yearsOfExperience
//        && servicesProvided && personnel)
//        {
//            this.btnAddSupportPersonnel.Enabled = true;
//        }
//        else
//        {
//            this.btnAddSupportPersonnel.Enabled = false;
//        }
//    }

//}

//private void cbxID_SelectedIndexChanged_1(object sender, EventArgs e)
//{
//    if (cbxID.SelectedIndex > -1)
//    {
//        empty = true;
//        if (notSimilarName && nameOfPersonnel && personnelID && empty && yearsOfExperience
//          && servicesProvided && personnel)
//        {
//            this.btnAddSupportPersonnel.Enabled = true;
//        }
//        else
//        {
//            this.btnAddSupportPersonnel.Enabled = false;
//        }
//    }

//}










//for (int i = 0; i < AllFormClass.SupportPersonnels.Count; i++)
//{
//    SupportPersonnels s = (SupportPersonnels)AllFormClass.SupportPersonnels[i];
//    string searchPersonnel = s.NameOfPersonnel.ToString();
//    if (searchPersonnel.Contains(tbxDeleteSearch.Text))
//    {
//        listBoxDeleteResultPersonnel.DisplayMember = "Name of personnel: ";
//        listBoxDeleteResultPersonnel.Items.Add(AllFormClass.SupportPersonnels[i]);
//    }
//}
        



     





    




    

